// pages/cart/cart.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    num: 1,
    isChecked: 1,
    ltd: 'banding',
    league: {
      name: 'zac',
      skillpoint: 18,
      skillkind: 5,
      kind: 'tank'
    },
    animalList: ['Zac', 'Sam', 'KFC', 'Zyra'],
    numList: [100, 101, 102, 103, 104, 110],
    fruitList: [{
      id: 1,
      name: '',
      price: 66
    }, {
      id: 12,
      name: '🌰',
      price: 77
    }, {
      id: 13,
      name: '🍍',
      price: 68
    }]
  },

  updateNum(event) {
    console.log(event)
    this.setData({
      num: this.data.num + this.data.num
    })
  },

  updateLeague() {
    this.setData({
      'league.name': 'Lulu',
      skillkind: 2
    })
  },

  updateLeagueByES6() {
    const league = {
      ...this.data.league,
      name: 'Teemo',
      kind: 'marksman'
    }

    this.setData({
      league
    })
  },

  readLeague() {
    league: this.data.league
  },
  deconstructLeague() {
    // 将 league 从 data 中进行解构
    const league = this.data
    const newLeague = {
      ...league,
      name: 'Lux',
      kind: 'master'
    }
    this.setData({
      league: newLeague
    })
  },

  ass() {
    const league = Object.assign(
      this.data.league, {
        name: 'cc'
      }, {
        kind: 'unknown'
      }
    )
    this.setData({
      league
    })
  },
  deleteLeagueKind() {
    const newLeague = {
      ...this.data.league
    }
    delete newLeague.kind
    this.setData({
      league: newLeague
    })
  },

  concatArray() {
    const newArray = this.data.animalList.concat('Jax')
    this.setData({
      animalList: newArray
    })
  },
  pushArray() {
    this.data.animalList.push('earth')
    this.setData({
      animalList: this.data.animalList
    })
  },
  ES6Array() {
    const newArray = [...this.data.animalList, 'CC']
    this.setData({
      animalList: newArray
    })
  },
  updateArray() {
    this.setData({
      'animalList[2]': 'DKS'
    })
  },

  filterArray() {
    const filterList = this.data.animalList.filter(item => item !== 'Zac')
    this.setData({
      animalList: filterList
    })
  },
  navigateBack() {
    wx.navigateBack({
      // 关闭当前页面，返回上一页或者返回多级页面
      // 默认返回上一页
      delta: 1
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
    console.log('template_test 页面卸载')
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})